# Contributor: Andy Postnikov <apostnikov@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>

pkgname=php7-pecl-igbinary
_pkgreal=igbinary
pkgver=3.1.2
pkgrel=2
pkgdesc="Igbinary is a drop in replacement for the standard php serializer"
url="https://pecl.php.net/package/igbinary"
arch="all"
license="BSD-3-Clause"
provides="php7-igbinary=$pkgver-r$pkgrel" # for backward compatibility
replaces="php7-igbinary" # for backward compatibility
depends="php7-common"
makedepends="php7-dev php7-pecl-apcu"
checkdepends="php7-json php7-session" # sessions needs work https://github.com/igbinary/igbinary/issues/116
source="$pkgname-$pkgver.tgz::https://pecl.php.net/get/$_pkgreal-$pkgver.tgz
	fix-apcu-tests.patch::https://github.com/igbinary/igbinary/pull/276.patch
	0001-Update-tests-of-serializing-ArrayObject-for-7.4.6.patch"
builddir="$srcdir/$_pkgreal-$pkgver"

build() {
	phpize7
	./configure \
		--prefix=/usr \
		--with-php-config=/usr/bin/php-config7
	make
}

check() {
	local modules="/usr/lib/php7/modules"
	# Tests require extra extensions which are not bundled
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		PHP_TEST_SHARED_EXTENSIONS="
		-d extension=$modules/apcu.so \
		-d extension=$modules/json.so \
		-d extension=$modules/session.so \
		-d extension=modules/$_pkgreal.so"
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	install -d "$pkgdir"/etc/php7/conf.d
	echo "extension=$_pkgreal.so" > \
		"$pkgdir"/etc/php7/conf.d/10_$_pkgreal.ini
}

sha512sums="8d293b63e64a2759d55569fda9f9641c34dd9cc1529612d22821f8026b09010e35e2f36552f88e4af89c64a81a9a1548e012b176e2fedab74f839bf7699168c2  php7-pecl-igbinary-3.1.2.tgz
11933bfcabd3d0dba677c290139059ea9b8510c1a3748f1e34949b23f7163c6bbc05222b7d42892515b1e7c2585d3261ad6be0182a95ee71e22ea9bc0b39788d  fix-apcu-tests.patch
b7f8c05d6f60f5ba17f64ca3bc057e693ffcbf9a73f87e41af102ebb5818e32045f2275d54452a3219351c0186107b3f3d147b6e55af78bb77980f8008590d1d  0001-Update-tests-of-serializing-ArrayObject-for-7.4.6.patch"
